/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef _RANGING_FILE_READER_HPP
#define _RANGING_FILE_READER_HPP

#include "owndebug.h"
#include <string>
#include "RangingData.hpp"
#include "gimutils.h"
#include "ownutils.h"
#include <map>
#include <list>
#include <string>
#include <stdio.h>

typedef std::map<gim::time,MaCI::Ranging::CRangingData *> TRangingDataMap;

class CRangingFileReader{
public:
  /**
   * Constructor
   */
  CRangingFileReader();

  /**
   * Destructor
   */
  ~CRangingFileReader();

  /**
   * Opens file with wanted filename
   */
  bool ReadFile(std::string aFileName);

 
  bool GetServiceInformation(std::string &aMaCIGroup,
                             std::string &aInstanceName);

  bool GetDeviceLimits(MaCI::Ranging::TDeviceInformationLimits &aLimits);
  bool GetDevicePosition(MaCI::Ranging::TDeviceInformationPosition &aPosition);

  bool GetTimes(std::list<gim::time> &aTimes);
  bool GetTimeLimits(gim::time &aBegin,gim::time &aEnd);

  bool GetAllData(TRangingDataMap &aData);
  

  bool GetDistanceArray(MaCI::Ranging::CRangingData &aData,
                        gim::time aTime);

  
  
private:
  bool iFileReaded;  
  TRangingDataMap iData;
  std::list<gim::time> iTimes;
  gim::time iBegin;
  gim::time iEnd;
  std::string iMaCIGroup;
  std::string iInstanceName;
  MaCI::Ranging::TDeviceInformationLimits iDeviceLimits;
  MaCI::Ranging::TDeviceInformationPosition iDevicePosition;
 


  bool ReadData(FILE *iFile);
  
  CRangingFileReader(const CRangingFileReader&)
    :iFileReaded(false),
     iData(),
     iTimes(),
     iBegin(),
     iEnd(),
     iMaCIGroup(""),
     iInstanceName(""),
     iDeviceLimits(),
     iDevicePosition(){}

  CRangingFileReader &operator=(const  CRangingFileReader&){return *this;}

};
#endif ///< _RANGING_FILE_READER_HPP
